package com.ruoyi.web.controller.order;


import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.order.domain.OrderPayment;
import com.ruoyi.order.service.IOrderPaymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 订单支付信息Controller
 *
 * @author HHAOYU
 * @date 2020-12-14
 */
@RestController
@RequestMapping("/order/orderPayment")
public class OrderPaymentController extends BaseController
{
    @Autowired
    private IOrderPaymentService orderPaymentService;

    /**
     * 查询订单支付信息列表
     */
    @PreAuthorize("@ss.hasPermi('cinema:orderPayment:list')")
    @GetMapping("/list")
    public TableDataInfo list(OrderPayment orderPayment)
    {
        startPage();
        List<OrderPayment> list = orderPaymentService.selectOrderPaymentList(orderPayment);
        return getDataTable(list);
    }

    /**
     * 导出订单支付信息列表
     */
    @PreAuthorize("@ss.hasPermi('cinema:orderPayment:export')")
    @Log(title = "订单支付信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(OrderPayment orderPayment)
    {
        List<OrderPayment> list = orderPaymentService.selectOrderPaymentList(orderPayment);
        ExcelUtil<OrderPayment> util = new ExcelUtil<OrderPayment>(OrderPayment.class);
        return util.exportExcel(list, "orderPayment");
    }

    /**
     * 获取订单支付信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('cinema:orderPayment:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(orderPaymentService.selectOrderPaymentById(id));
    }

    /**
     * 新增订单支付信息
     */
    @PreAuthorize("@ss.hasPermi('cinema:orderPayment:add')")
    @Log(title = "订单支付信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderPayment orderPayment)
    {
        return toAjax(orderPaymentService.insertOrderPayment(orderPayment));
    }

    /**
     * 修改订单支付信息
     */
    @PreAuthorize("@ss.hasPermi('cinema:orderPayment:edit')")
    @Log(title = "订单支付信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderPayment orderPayment)
    {
        return toAjax(orderPaymentService.updateOrderPayment(orderPayment));
    }

    /**
     * 删除订单支付信息
     */
    @PreAuthorize("@ss.hasPermi('cinema:orderPayment:remove')")
    @Log(title = "订单支付信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(orderPaymentService.deleteOrderPaymentByIds(ids));
    }
}
